package com.leetcode.string;

import java.util.Scanner;

public class CountAndSay {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            int n = scanner.nextInt();
            System.out.println(solver(n));
        }
    }

    public static String solver(int n) {
        String res = "1";
        for (int i = 2; i <= n; i++) {
            int start = 0;
            int pos = 0;
            int len = res.length();
            StringBuilder builder = new StringBuilder();
            while(pos < len) {
                while(pos < len && res.charAt(start) == res.charAt(pos)) {
                    pos++;
                }
                builder.append(pos-start).append(res.charAt(start));
                start = pos;
            }
            res = builder.toString();
        }
        return res;
    }
}
